<template>
	<view class="container">
		<u-navbar title="详情" is-fixed
			background="url('https://www.yplm888.com//uploads/20220803/7ed305f9a93ba50b049a7725662b18cc.png') no-repeat">
		</u-navbar>
		<view>
			<player-component :vid="videoInfo.vid" :defn="shd" :usePoster="true" :posterUrl="videoInfo.cover_image" :autoPauseIfOpenNative="false" autoPauseIfNavigate="false" :pictureInPictureMode="['push', 'pop']"></player-component>
		</view>
		<view class="detail">
			<view class="">
				<text class="name">{{videoInfo.name}}</text>
			</view>
			<view class="secend-line">
				<u-icon class='icon' name="eye"></u-icon><text
					style="margin-right: 30rpx;">{{videoInfo.reading_volume}}</text>
				<u-icon class='icon' name="calendar"></u-icon>
				<text>{{videoInfo.createtime}}</text>
			</view>
			<view class="play-button" v-if="videoInfo.type==2" @click="toAudioDetail">
				<u-icon name="play-circle-fill" color="#fe466b" size="30"></u-icon>
				<view class="text">
					播放音频
				</view>
			</view>
			<view class="right" @click="changeCollect" v-if="pageType!='jiayouzhan'">
				<u-icon v-if="!isCollect" name="star" color='#ccc' size="40"></u-icon>
				<u-icon v-else name="star-fill" color='#FE5477' size="40"></u-icon>
			</view>
		</view>
		<scroll-view scroll-y="true" v-if="videoInfo.content" :style="'height:' + scrollH+'rpx;'">
			<view class="content-text">
				<view class="font-style-xie">大纲</view>
				<u-parse style='margin: 20rpx 0;' :html="videoInfo.outline_content"></u-parse>
				<view class="font-style-xie">详情</view>
				<u-parse :html="videoInfo.content"></u-parse>
			</view>
		</scroll-view>
		<!-- 更多视频 -->
		<view class="model" v-if="videoInfo.otherLst">
			<view class="font-style-xie">更多<text class="video-num">数量：{{videoInfo.otherLst.length}}</text></view>
			<scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll">
				<view class="show-item" v-for="(item, index) in videoInfo.otherLst" :key="item.id">
					<view class="image" @click="toPlay(item)">
						<image class="image" :src="item.cover_image" mode=""></image>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				videoInfo: '',
				id: '',
				scrollH: 0
			}
		},
		onLoad(option) {
			uni.setNavigationBarTitle({
				title: option.title
			})
			this.id = option.id
			this.initData(option.id)
		},
		onReady() {
			let that = this;
			uni.getSystemInfo({
				success: function(res) {
					that.scrollH = res.windowHeight * 750 / res.windowWidth;
					// #ifdef MP-WEIXIN
					that.scrollH = res.windowHeight * 750 / res.windowWidth - parseInt(res.safeArea.top) - 750;
					// #endif
				}
			});
		},
		methods: {
			initData(id) {
				this.$u.api['BrandstoryInfo']({id}).then(res => {
					this.videoInfo = res.data
					this.isCollect = res.data.is_collection
					if (res.data.is_subscribe == 0) {
						this.messageShow = true
					}
				})
			},
			scroll: function(e) {
				this.old.scrollTop = e.detail.scrollTop
			},
			// 收藏
			changeCollect() {
				this.$u.api.collect({
					collection_id: this.videoInfo.id,
					collection_type: 7
				}).then(res => {
					if (res.code == 1) {
						this.isCollect = !this.isCollect
						uni.showToast({
							title: res.msg
						})
					}
				})
			},

		}
	}
</script>

<style lang="scss">
	.container {
		position: relative;
		width: 100%;

		.cover {
			width: 100%;

			.cover-image {
				width: 100%;
				height: 400rpx;
				z-index: 66;
				position: absolute;
				top: 185rpx;
				right: 0;
			}
		}

		.cover-image {
			width: 100%;
			height: 400rpx;
			z-index: 66;
			position: absolute;
			top: 185rpx;
			right: 0;
		}
	}

	.video-wrap {
		text-align: center;
		width: 100%;
		height: 400rpx;
		background-color: #000000;
	}

	.detail {
		padding: 0 20rpx;
		margin: 0 20rpx;
		margin-top: 20rpx;
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
		position: relative;

		.name {
			font-size: 36rpx;
			margin-left: 10rpx;
			font-weight: 700;
			width: 90%;
		}

		.secend-line {
			color: #ccc;
			margin-left: 10rpx;
			padding-bottom: 10rpx;

			.icon {
				margin-right: 20rpx;
			}

		}

		.play-button {
			color: #FE5477;
			position: absolute;
			width: 150rpx;
			align-items: center;
			display: flex;
			flex-direction: column;
			bottom: 15rpx;
			right: 60rpx;

			.text {
				font-size: 20rpx;
			}
		}

		.right {
			position: absolute;
			bottom: 20rpx;
			right: 20rpx;
		}
	}

	.content-text {
		margin-top: 10rpx;
		margin: 30rpx;
		padding-bottom: 20rpx;
	}

	.font-style-xie {
		font-weight: 700;
		font-size: 32rpx !important;
		font-style: italic;

		.video-num {
			font-style: normal;
			font-weight: normal;
			font-size: 16rpx;
			color: #FE5477;
			float: right;
			margin-right: 10rpx;
			margin-top: 10rpx;
		}
	}

	.model {
		height: 300rpx;
		margin-top: 40rpx;
		padding: 0 40rpx;

		.scroll-view_H {
			margin-top: 20rpx;
			white-space: nowrap;
			width: 100%;

			.show-item {
				display: inline-block;

				.image {
					height: 150rpx;
					width: 200rpx;
					border-radius: 20rpx;
					margin-right: 20rpx;
					background-color: #ccc;

					.image {
						height: 150rpx;
						width: 200rpx;
						border-radius: 20rpx;
					}
				}
			}
		}
	}
</style>